﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ZXing.Common;
using ZXing;
using ZXing.QrCode;
using System.Drawing;

namespace WAD.WEB.AppCode
{
    /// <summary>
    /// 二维码操作类
    /// </summary>
    public class Barcode
    {
        /// <summary>
        /// 生成二维码
        /// </summary>
        /// <param name="code"></param>
        /// <param name="w">图片宽</param>
        /// <param name="h">高</param>
        /// <returns></returns>
        public static Bitmap MakeQrcode(String code,int size) {

            EncodingOptions options = null;
            BarcodeWriter writer = null; 
            options = new QrCodeEncodingOptions
            {
                DisableECI = true,
                CharacterSet = "UTF-8",
                Width = size,
                Height = size
            };
            writer = new BarcodeWriter();
            writer.Format = BarcodeFormat.QR_CODE;
            writer.Options = options;
            return writer.Write(code);
        }
    }
}